package cn;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.List;

public class HomeToUserForm extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String myUser = req.getParameter("userid");
        List<Userid> userList = new ArrayList<>();
        try {
            DatabaseConnection databaseConnection = new DatabaseConnection();
            IUserDAO iUserDAO = new UserDAOImpl(databaseConnection.getConnection());
            userList = iUserDAO.findSomeUser(myUser);

        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("查询到的记录数=" + userList.size());
        RequestDispatcher rd;
        req.setAttribute("userSomeUsers", userList);
        rd = req.getRequestDispatcher("/Login/UserForm.jsp");
        rd.forward(req, resp);
        req.setAttribute("userSomeUsers",UserDAOImpl.class);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }
}
